﻿using Microsoft.CodeAnalysis.CSharp.Syntax;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UMLSynthesizer.CSharpAnalyzer.Elements;
using UMLSynthesizer.CSharpAnalyzer.Helpers;
using UMLSynthesizer.LangAnalyzer.Elements;
using UMLSynthesizer.LangAnalyzer.Expressions;
using UMLSynthesizer.LangAnalyzer.Statements;

namespace UMLSynthesizer.CSharpAnalyzer.Expressions
{
    class CSharpArrayCreationExpression : CSharpExpressionBase, IArrayCreationExpression
    {
        #region Fields

        CSharpExpressionHelper initExprHelper;

        #endregion

        #region Constructor

        public CSharpArrayCreationExpression(ArrayCreationExpressionSyntax expressionNode,
            IExpressionBase parentExpression,
            IStatementBase parentStatement)
            : base(expressionNode, parentExpression, parentStatement, ExpressionKinds.ArrayCreation)
        { initExprHelper = new CSharpExpressionHelper(this, parentStatement, () => expressionNode.Initializer); }

        #endregion

        #region Properties

        public ITypeBase Type
        {
            get
            {
                return (ProjectOwner as CSharpProjectElement)
                    .GetTypeReference((expressionNode as ArrayCreationExpressionSyntax).Type);
            }
        }
        public IExpressionBase Initializer { get { return initExprHelper.Expression; } }

        #endregion
    }
}
